﻿using System;
using System.Collections.Generic;
using System.IOC;
using System.Linq;
using System.Web;

namespace HynuIOTA.Web
{
    public class IOCConfig
    {
        public static void InitIOCContainer()
        {
            var ioc = IOContainer.GetInstance();

            // 数据层 仓储接口和仓储示例绑定
            ioc.Bind("HynuIOTA.IRespository,HynuIOTA.IRespository.IDBSession", "HynuIOTA.Respository,HynuIOTA.Respository.DBSession")
                .SetCreationMethod("HynuIOTA.IRespository,HynuIOTA.IRespository.IDBSession", CreationMethodEnum.Singleton);

            // 服务层 仓储接口和仓储实例绑定
            ioc.Bind("HynuIOTA.IService,HynuIOTA.IService.IServiceSession", "HynuIOTA.Service,HynuIOTA.Service.ServiceSession")
                .SetCreationMethod<IService.IServiceSession>(CreationMethodEnum.Singleton);

            // 预热生成
            Type respository = ioc.GetTypeByString("HynuIOTA.IRespository,HynuIOTA.IRespository.IDBSession");
            var respositoryObj = ioc.Get(respository);
            var service = ioc.Get<IService.IServiceSession>();
        }
    }
}